<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>更改 HTML 元素的内容为 JavaScript 变量的值</title>
</head>

<body>
    <div id="change" class="change">
        <h1>{{ info }}</h1>
    </div>

    <script>
        let info = "Hello, World!"

        let element = document.querySelector("#change > h1")
        console.log(element);

        console.log(element.textContent);
        // let content = element.textContent.replace('{{', '').replace('}}', '').replace(' ','')
        // console.log(content);

        // console.log(eval(content));

        // element.textContent = eval(content)

        console.log(eval(element.textContent));
        element.textContent = eval(element.textContent)
        
               
        
    </script>
</body>

</html>